/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Modelo;

import com.mysql.jdbc.Connection;
import java.io.Serializable;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;

/**
 *
 * @author LOTICA
 */
public class Conection implements Serializable {
private transient Connection con;
	private String jdbcDriver;
	private String databaseURL;
	private String user;
	private String password;
	ResultSet rs;

	public void connect() throws SQLException{
		if(this.isConnect())
		  throw new SQLException("Ya Esta Conectado");
        try{
           Class.forName("com.mysql.jdbc.Driver").newInstance();
           con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/Base","root","tibocha");
		}catch(Exception y){
			JOptionPane.showMessageDialog(null, y.toString() , "Error al Tratar de conectar",JOptionPane.DEFAULT_OPTION);
		}



	}


        public void disconnect(){
            if(con!=null){
               try{
                   con.close();
               }catch (SQLException ignore){

               }
               finally {
                   con=null;
               }
            }
        }

	public boolean isConnect(){
	 	if(con==null)
	 	   return false;

	 	   else
	 	   return true;
	}

    public Connection getCon() {
        return con;
    }

    public void setCon(Connection con) {
        this.con = con;
    }

    public String getDatabaseURL() {
        return databaseURL;
    }

    public void setDatabaseURL(String databaseURL) {
        this.databaseURL = databaseURL;
    }

    public String getJdbcDriver() {
        return jdbcDriver;
    }

    public void setJdbcDriver(String jdbcDriver) {
        this.jdbcDriver = jdbcDriver;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public ResultSet getRs() {
        return rs;
    }

    public void setRs(ResultSet rs) {
        this.rs = rs;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }


}
